﻿@model KL.Store.Web.Models.StokGrupDuzenleModel
@using KL.Store.Core
@{
    Layout = null;
    var item = Model.Category;
}
@using (Ajax.BeginForm("KategoriDuzenle2", "ReportPanel", null, new AjaxOptions { HttpMethod = "Post", OnBegin = "loadingMsg();" }, new { id = "categoryedit", name = "categoryedit", @class = "form-horizontal editform" }))
{
    <input type="hidden" value="@(Model.Category.CategoryId)" name="Category.OrgCategoryId" />
    <input type="hidden" value="1" name="IdForPost" />
    <div class="col-xs-10 first">
        @if (!string.IsNullOrEmpty(Model.Message))
        {
            <div class="form-group">
                <div class="col-xs-6 first">
                    <label>
                        @Model.Message
                    </label>
                </div>
            </div>
            <hr />
        }
        @if (Model.AddNew)
        {
            <input type="hidden" name="Category.CategoryId" value="0" />
            <input type="hidden" name="Category.ProductGroupCode" value="0" />
            <input type="hidden" name="Category.GroupCode" value="0" />
        }
        else
        {
            <div class="form-group">
                <div class="col-xs-6 first">
                    <label for="Category_CategoryId">Grup No<span class="requireStar">*</span>: </label>
                    @Html.TextBoxFor(model => model.Category.CategoryId, new { @class = "form-control", @placeHolder = "Grup No giriniz" })
                </div>
                <div class="col-xs-6 first last">
                    <label for="Category_ProductGroupCode">Ürün Grup Kodu: </label>
                    @Html.TextBoxFor(model => model.Category.ProductGroupCode, new { @class = "form-control", @placeHolder = "Ürünün Grup No giriniz" })
                </div>
            </div>
        }
        <div class="form-group">
            <div class="col-xs-12 first last">
                <label for="Category_CategoryName">Grup Adı<span class="requireStar">*</span>: </label>
                @Html.TextBoxFor(model => model.Category.CategoryName, new { @class = "form-control", @placeHolder = "Grup Adı giriniz" })
            </div>
        </div>

        <div class="form-group">
            <div class="col-xs-3 first">
                <label for="Category_ParentCategoryId">Üst Grup No<span class="requireStar">*</span>: </label>
                @Html.TextBoxFor(model => model.Category.ParentCategoryId, new { @class = "form-control", @placeHolder = "Üst Grup No giriniz" })
            </div>
            <div class="col-xs-9 first last">
                <label for="Category_ParentCategoryName">&nbsp;</label>
                @Html.TextBoxFor(model => model.Category.ParentCategoryName, new { @class = "form-control", @disabled = "disabled" })
            </div>
        </div>

        <div class="form-group">
            <div class="col-xs-6 first">
                <label for="Category_CategoryType">Grup Tipi: </label>
                <select name="Category.CategoryType" id="Category_CategoryType" class="form-control">
                    <option value="">Seçiniz</option>
                    <option value="A"@{if (Model.Category.CategoryType == "A")
                                       {<text> selected="selected"</text>}}>A - Ana Ürün Grubu</option>
                    <option value="F"@{if (Model.Category.CategoryType == "F")
                                       {<text> selected="selected"</text>}}>F - Fiyat Grubu</option>
                    <option value="M"@{if (Model.Category.CategoryType == "M")
                                       {<text> selected="selected"</text>}}>M - Marka</option>
                    <option value="S"@{if (Model.Category.CategoryType == "S")
                                       {<text> selected="selected"</text>}}>S - Sayfa Grubu</option>
                    <option value="D"@{if (Model.Category.CategoryType == "D")
                                       {<text> selected="selected"</text>}}>D - Diğer</option>
                    <option value="Ü"@{if (Model.Category.CategoryType == "Ü")
                                       {<text> selected="selected"</text>}}>Ü - Üst Grup</option>
                </select>
            </div>
            @if (!Model.AddNew)
            {
                <div class="col-xs-6 first last">
                    <label for="Category_GroupCode">Grup Kodu (Sıralama): </label>
                    @Html.TextBoxFor(model => model.Category.GroupCode, new { @class = "form-control", @placeHolder = "Grup Kodu giriniz" })
                </div>
            }
        </div>

        <div class="form-group">
            <div class="col-xs-12 first last">
                <label for="Category_WebDescription">Web Açıklama: </label>
                @Html.TextBoxFor(model => model.Category.WebDescription, new { @class = "form-control", @placeHolder = "Web Açıklaması giriniz" })
            </div>
        </div>

        <div class="form-group">
            <div class="col-xs-12 first last">
                <label for="Category_WebKeywords">Web Etiket: </label>
                @Html.TextBoxFor(model => model.Category.WebKeywords, new { @class = "form-control", @placeHolder = "Web Etiketi giriniz" })
            </div>
        </div>

        <div class="form-group">
            <div class="col-xs-4 first">
                <div class="checkbox">
                    <label>
                        @Html.CheckBoxFor(model => model.Category.ShowOnEStore)
                        eStore'da Görünsün
                    </label>
                </div>
                <div class="checkbox">
                    <label>
                        @Html.CheckBoxFor(model => model.Category.BannerActive)
                        Banner Aktif
                    </label>
                </div>
            </div>
            <div class="col-xs-4 first">
                <label for="Category_eStoreRowCount">eStore Sütun Sayısı: </label>
                <select name="Category.eStoreRowCount" id="Category_eStoreRowCount" class="form-control">
                    <option value="0">Seçiniz</option>
                    <option value="1"@{if (Model.Category.eStoreRowCount == 1)
                                       {<text> selected="selected"</text>}}>1</option>
                    <option value="2"@{if (Model.Category.eStoreRowCount == 2)
                                       {<text> selected="selected"</text>}}>2</option>
                    <option value="3"@{if (Model.Category.eStoreRowCount == 3)
                                       {<text> selected="selected"</text>}}>3</option>
                    <option value="4"@{if (Model.Category.eStoreRowCount == 4)
                                       {<text> selected="selected"</text>}}>4</option>
                    <option value="6"@{if (Model.Category.eStoreRowCount == 6)
                                       {<text> selected="selected"</text>}}>6</option>
                </select>
            </div>
            <div class="col-xs-4 first last">
                <label for="Category_eStoreImageType">eStore Resim Tipi: </label>
                <select name="Category.eStoreImageType" id="Category_eStoreImageType" class="form-control">
                    <option value="">Standart</option>
                    <option value="w"@{if (Model.Category.eStoreImageType == "w")
                                       {<text> selected="selected"</text>}}>Geniş (Ör: 16:9)</option>
                    <option value="s"@{if (Model.Category.eStoreImageType == "s")
                                       {<text> selected="selected"</text>}}>Kare (Ör: 1:1)</option>
                    <option value="t"@{if (Model.Category.eStoreImageType == "t")
                                       {<text> selected="selected"</text>}}>Uzun (Ör: 9:16)</option>
                </select>
            </div>
        </div>

        <div class="form-group">
            <div class="col-xs-3 first">
                <label for="Category_BasketGroupNo">Sepet Grup No: </label>
                @Html.TextBoxFor(model => model.Category.BasketGroupNo, new { @class = "form-control", @placeHolder = "Sepet Grup No giriniz" })
            </div>
            <div class="col-xs-9 first last">
                <label for="Category_BasketGroupName">&nbsp;</label>
                @Html.TextBoxFor(model => model.Category.BasketGroupName, new { @class = "form-control", @disabled = "disabled" })
            </div>
        </div>

        <div class="form-group">
            <div class="col-xs-3 first">
                <label for="Category_BasketMinPrice">Sepet Min. Tutarı: </label>
                @Html.TextBoxFor(model => model.Category.BasketMinPrice, new { @class = "form-control", @placeHolder = "Sepet Min. Tutarı giriniz" })
            </div>
            <div class="col-xs-3 first">
                <div class="checkbox">
                    <label>
                        @Html.CheckBoxFor(model => model.Category.BasketMinNotice)
                        Min. Sepet Uyarısı Göster
                    </label>
                </div>
            </div>
            <div class="col-xs-3 first">
                <div class="checkbox">
                    <label>
                        @Html.CheckBoxFor(model => model.Category.ShowModelOnProductDetails)
                        Ürün Detayda Model Göster
                    </label>
                </div>
            </div>
            <div class="col-xs-3 first last">
                <div class="checkbox">
                    <label>
                        @Html.CheckBoxFor(model => model.Category.FreeCargoInCity)
                        Ş.içi Ücretsiz Kargo
                    </label>
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-xs-3 first">
                <label for="Category_CargoPrice">Kargo Ücreti: </label>
                @Html.TextBoxFor(model => model.Category.CargoPrice, new { @class = "form-control", @placeHolder = "Kargo Ücreti giriniz" })
            </div>
            <div class="col-xs-3 first">
                <label for="Category_InstallmentPrice">Montaj Bedeli: </label>
                @Html.TextBoxFor(model => model.Category.InstallmentPrice, new { @class = "form-control", @placeHolder = "Montaj Bedeli giriniz" })
            </div>
            <div class="col-xs-3 first">
                <label for="Category_Desi">Desi: </label>
                @Html.TextBoxFor(model => model.Category.Desi, new { @class = "form-control", @placeHolder = "Desi giriniz" })
            </div>
            <div class="col-xs-3 first last">
                <div class="checkbox">
                    <label>
                        @Html.CheckBoxFor(model => model.Category.FreeCargo)
                        Ücretsiz Kargo
                    </label>
                </div>
                <div class="checkbox">
                    <label>
                        @Html.CheckBoxFor(model => model.Category.Transport)
                        Nakliye
                    </label>
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-xs-3 first">
                <label for="Category_SuggestedGroup">Önerilen Grup No: </label>
                @Html.TextBoxFor(model => model.Category.SuggestedGroup, new { @class = "form-control", @placeHolder = "Önerilen Grup No giriniz" })
            </div>
            <div class="col-xs-3 first">
                <label for="Category_ShowcaseGroup">Vitrin Grup No: </label>
                @Html.TextBoxFor(model => model.Category.ShowcaseGroup, new { @class = "form-control", @placeHolder = "Vitrin Grup No giriniz" })
            </div>
            <div class="col-xs-3 first">
                <label for="Category_MaxInstallmentCount">En Yüksek Taksit: </label>
                @Html.TextBoxFor(model => model.Category.MaxInstallmentCount, new { @class = "form-control", @placeHolder = "En Yüksek Taksit Sayısı giriniz" })
            </div>
            <div class="col-xs-3 first last">
                <label for="Category_ProductListCount">Listelenecek Ürün Sayısı: </label>
                @Html.TextBoxFor(model => model.Category.ProductListCount, new { @class = "form-control", @placeHolder = "Listelenecek Ürün Sayısı giriniz" })
            </div>
        </div>

        <div class="form-group">
            <div class="col-xs-12 first last">
                <label for="Category_ProductQuestionString">Soru Formu Metni: </label>
                @Html.TextBoxFor(model => model.Category.ProductQuestionString, new { @class = "form-control", @placeHolder = "Soru Formu Metni giriniz" })
            </div>
        </div>

        <div class="form-group">
            <div class="col-xs-12 first last">
                <label for="Category_WebTitle">Web Title (Sayfa Başlığı): </label>
                @Html.TextBoxFor(model => model.Category.WebTitle, new { @class = "form-control", @placeHolder = "Web Title giriniz" })
            </div>
        </div>
        @if (Model.AddNew)
        {
            <input type="hidden" name="Category.Canonical" value="" />
        }
        else
        {
            <div class="form-group">
                <div class="col-xs-12 first last">
                    <label for="Category_Canonical">Canonical Link: </label>
                    @Html.TextBoxFor(model => model.Category.Canonical, new { @class = "form-control", @placeHolder = "Canonical Link giriniz" })
                </div>
            </div>
        }

    </div>
    <div class="col-xs-2 last categoryEditButtons">
        <ul>
            @if (Model.AddNew)
            {
                <li>
                    <button type="submit" class="btn btn-success">Ekle</button>
                </li>
                <li>
                    <button type="button" class="btn btn-warning" onclick="eklemeIptal(@(Model.Category.ParentCategoryId));">İptal</button>
                </li>
            }
            else
            {
                <li>
                    <button type="submit" class="btn btn-success">Kaydet</button>
                </li>
                <li>
                    <button type="button" class="btn btn-primary" onclick="AddNewCategory(@(Model.Category.CategoryId));">Alt Kategori Ekle</button>
                </li>
                <li>
                    <button type="button" class="btn btn-danger" onclick="kategoriSil(@(Model.Category.CategoryId), @(Model.Category.ParentCategoryId), @(Model.Category.RelatedProductCount))">Kategoriyi Sil</button>
                </li>
            }
        </ul>
    </div>
}
<div class="clearfix"></div>
@if (!Model.AddNew)
{
    <div class="col-xs-10 first" id="CategoryEditExtraFields">
        <form class="form-horizontal">
            <div class="form-group">
                <table id="CategoryEditExtraFieldsUpdate" class="table table-bordered">
                    <thead>
                        <tr>
                            <td>#</td>
                            <td>Açıklama</td>
                            <td>Bilgi</td>
                            <td>Ürün Listesinde Göster</td>
                        </tr>
                    </thead>
                    <tbody>
                        @{var counter = 1;}
                        @foreach (var field in Model.ExtraFields)
                        {
                            <tr data-counter="@(counter)">
                                <td>
                                    <input type="text" name="SatirNo@(field.SatirNo)" data-satirno="@(field.SatirNo)" data-idgrup="@(field.CategoryId)" data-field="SATIRNO" data-orgg="@(field.SatirNo)" value="@(field.SatirNo)" />
                                </td>
                                <td>
                                    <input type="text" name="Aciklama@(field.SatirNo)" data-satirno="@(field.SatirNo)" data-idgrup="@(field.CategoryId)" data-field="ACIKLAMA" data-orgg="@(field.Title)" value="@(field.Title)" />
                                </td>
                                <td>
                                    <input type="text" name="Bilgi@(field.SatirNo)" data-satirno="@(field.SatirNo)" data-idgrup="@(field.CategoryId)" data-field="BILGI" data-orgg="@(field.Value)" value="@(field.Value)" />
                                </td>
                                <td>
                                    <select name="EstoreGoster@(field.SatirNo)" data-satirno="@(field.SatirNo)" data-idgrup="@(field.CategoryId)" data-field="ESTOREGOSTER" data-orgg="@(field.ShowOnEstore)" >
                                        <option value="0" @{ if (field.ShowOnEstore == 0)
                                                             { <text> selected="selected"</text>} }>Gösterme</option>
                                        <option value="1" @{ if (field.ShowOnEstore == 1)
                                                             { <text> selected="selected"</text>} }>Göster</option>
                                    </select>
                                </td>
                            </tr>
                                                             counter++;
                        }
                    </tbody>
                </table>
                <div class="alignright">
                    <button class="btn btn-success" type="button" onclick="AddExtraFieldHtml();">Alan Ekle</button>
                </div>
                <div id="AddExtraFieldPH"></div>
                <div style="display: none;" id="AddExtraFieldPHOrg">
                    <br />
                    <table class="table table-bordered">
                        <thead>
                            <tr>
                                <td>#</td>
                                <td>Açıklama</td>
                                <td>Bilgi</td>
                                <td>Ürün Listesinde Göster</td>
                            </tr>
                        </thead>
                        <tbody>
                            <tr data-counter="@(counter)">
                                <td>
                                    <input type="text" name="AddSatirNo" data-idgrup="@(Model.Category.CategoryId)" data-field="SATIRNO" />
                                </td>
                                <td>
                                    <input type="text" name="AddAciklama" data-idgrup="@(Model.Category.CategoryId)" data-field="ACIKLAMA" />
                                </td>
                                <td>
                                    <input type="text" name="AddBilgi" data-idgrup="@(Model.Category.CategoryId)" data-field="BILGI" />
                                </td>
                                <td>
                                    <select name="AddEstoreGoster" data-idgrup="@(Model.Category.CategoryId)" data-field="ESTOREGOSTER">
                                        <option value="0">Gösterme</option>
                                        <option value="1">Göster</option>
                                    </select>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                    <div class="alignright">
                        <button class="btn btn-warning" type="button" onclick="CancelAddExtraField();">İptal</button>
                        <button class="btn btn-success" type="button" onclick="AddExtraField();">Ekle</button>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <div class="clearfix"></div>
    <div class="col-xs-5 first form-horizontal">
        <div class="form-group">
            <form id="catImageUpload" class="upload" method="post" action="/Upload/RPImageUpload" enctype="multipart/form-data">
                <div id="catImageDrop" class="drop">
                    Kategori Resimini Buraya Sürükle<br />
                    <a>Gözat</a>
                    <input type="file" name="file" />
                </div>
                <ul>
                </ul>
                <input type="hidden" name="Id" value="@(Model.Category.CategoryId)"/>
                <input type="hidden" name="Password" value="@(Model.Password)" />
                <input type="hidden" name="ImageType" value="category" />
                <input type="hidden" name="ImageNo" value="0" />
                <input type="hidden" name="FileName" value="0" />
            </form>
            <div class="clearfix"></div>
        </div>
    </div>
    <div class="col-xs-5 form-horizontal">
        <div class="form-group">
            <form id="catBannerUpload" class="upload" method="post" action="/Upload/RPImageUpload" enctype="multipart/form-data">
                <div id="catBannerDrop" class="drop">
                    Banner Resmini Buraya Sürükle<br />
                    <a>Gözat</a>
                    <input type="file" name="file" />
                </div>
                <ul>
                </ul>
                <input type="hidden" name="Id" value="@(Model.Category.CategoryId)"/>
                <input type="hidden" name="Password" value="@(Model.Password)" />
                <input type="hidden" name="ImageType" value="category-banner" />
                <input type="hidden" name="ImageNo" value="0" />
                <input type="hidden" name="FileName" value="0" />
            </form>
            <div class="clearfix"></div>
        </div>
    </div>
}
